<template>
  <div class="dashboard-editor-container" style="overflow: hidden">
    <!-- <github-corner class="github-corner"  margin-top:12px;  /> -->

    <el-row style="width: 86.3%; top: 6px; z-index: 999; position: fixed">
      <el-col :span="20" class="card-box">
        <!-- <i class="el-icon-s-data" /><span style="font-weight:600;color:#666;margin-right: 450px;margin-left: 5px;">
          销售总览
        </span> -->
        <el-select
          v-if="activeName == 0"
          v-model="brandList"
          multiple
          placeholder="选择品牌"
          filterable
          @change="changebrandList"
          style="width: 300px"
        >
          <el-option
            v-for="dict in dict.type.sys_product_pp"
            :key="dict.value"
            :label="dict.label"
            :value="dict.label"
          />
        </el-select>
        <el-cascader
          v-if="activeName != 0"
          class="region"
          v-model="salesGrade"
          placeholder="选择店铺分组"
          :options="cascadeList"
          :props="{ checkStrictly: true }"
          @change="handleChange"
          style="width: 300px; height: 30px"
        >
        </el-cascader>
      </el-col>
      <!-- <el-col :span="12" style="background-color: #f5f5f5; height: 30px">
        <nav id="navbar">
          <ul>
            <li :class="{ active: isActiveSection(1) }">
              <a href="#section1" @click="scrollToSection(1)">MTD</a>
            </li>
            <li :class="{ active: isActiveSection(2) }">
              <a href="#section2" @click="scrollToSection(2)">QTD</a>
            </li>
            <li :class="{ active: isActiveSection(3) }">
              <a href="#section3" @click="scrollToSection(3)">YTD</a>
            </li>
            <li :class="{ active: isActiveSection(4) }">
              <a href="#section4" @click="scrollToSection(4)">整体销售趋势</a>
            </li>
            <li :class="{ active: isActiveSection(5) }">
              <a href="#section5" @click="scrollToSection(5)">品牌销售额</a>
            </li>

            <li :class="{ active: isActiveSection(6) }">
              <a href="#section6" @click="scrollToSection(6)">渠道销售追踪</a>
            </li>
            
          </ul>
        </nav>
      </el-col> -->
      <el-col :span="4">
        <el-radio-group
          v-model="dateType"
          size="small"
          @change="getselectSaleTargetStatistics"
        >
          <el-radio-button
            v-for="(item, index) in typeArr"
            :key="index"
            :label="item.value"
            >{{ item.label }}</el-radio-button
          >
        </el-radio-group>
      </el-col>
      <!--<el-col :span="7">
         <date
          v-model="valueTime"
          :type.sync="groupType"
          @handleChangeTime="handleChangeTime($event)"
        ></date>
      </el-col> -->
    </el-row>
    <el-tabs v-model="activeName" @tab-click="handleClick" type="border-card">
      <el-tab-pane label="整体销售追踪" name="0">
        <section v-if="activeName == 0">
          <section id="section1" v-if="dateType == 'month'">
            <el-row :gutter="10" class="mb8" style="margin-bottom: 16px">
              <el-col :span="6">
                <el-card>
                  <div slot="header">
                    <span
                      ><i class="el-icon-pie-chart"></i>
                      {{ query.salesGrade + " " }}本月完成率</span
                    >
                  </div>
                  <card
                    v-if="dateType == 'month'"
                    :id="'monthly'"
                    :chartData="echartDatamonthly"
                    height="205px"
                    width="100%"
                  />
                  <!-- <div id="ginsengGauge" style="height: 200px"></div> -->
                  <div class="content">
                    <progressMonthly
                      :progressValue="biNumberItem.monthlyProgress"
                    />
                  </div>
                </el-card>
              </el-col>
              <el-col :span="18">
                <el-card>
                  <!-- <div slot="header">
              <span 
                ><i class="el-icon-collection"></i> 本月完成率</span
              >
            </div> -->
                  <panel-group
                    @handleSetLineChartData="handleSetLineChartData"
                    :biNumberItem="biNumberItem"
                  />
                </el-card>
              </el-col>
            </el-row>
          </section>

          <section id="section2" v-if="dateType == 'quarterly'">
            <!-- margin-bottom: 16px-->
            <el-row :gutter="10" style="margin-bottom: 16px">
              <el-col :span="6">
                <el-card>
                  <div slot="header">
                    <span
                      ><i class="el-icon-collection"></i
                      >{{ query.salesGrade + " " }} 季度完成率</span
                    >
                  </div>

                  <cardquarterly
                    v-if="dateType == 'quarterly'"
                    :id="'quarterly'"
                    :chartData="echartDataquarterly"
                    height="205px"
                    width="100%"
                  />
                  <!-- <div id="ginsengGauge" style="height: 200px"></div> -->
                  <div class="content">
                    <progressYear
                      :progressValue="biNumberItem.quarterlyProgress"
                    />
                  </div>
                </el-card>
              </el-col>
              <el-col :span="18">
                <el-card>
                  <!-- <div slot="header">
              <span 
                ><i class="el-icon-collection"></i> 本月完成率</span
              >
            </div> -->
                  <panel-group-i
                    @handleSetLineChartData="handleSetLineChartData"
                    :biNumberItem="biNumberItem"
                  />
                </el-card>
              </el-col>
            </el-row>
          </section>

          <section id="section3" v-if="dateType == 'year'">
            <el-row :gutter="10" style="margin-bottom: 16px">
              <el-col :span="6">
                <el-card>
                  <div slot="header">
                    <span
                      ><i class="el-icon-collection"></i>
                      {{ query.salesGrade + " " }}年度完成率</span
                    >
                  </div>
                  <!-- <card
              :id="'year'"
              :chartData="echartData"
              height="250px"
              width="100%"
            /> -->

                  <cardyear
                    v-if="dateType == 'year'"
                    :id="'year'"
                    :chartData="echartData"
                    height="205px"
                    width="100%"
                  />
                  <!-- <div id="ginsengGauge" style="height: 200px"></div> -->
                  <div class="content">
                    <progressYear :progressValue="biNumberItem.yearProgress" />
                  </div>
                </el-card>
              </el-col>
              <el-col :span="18">
                <el-card>
                  <!-- <div slot="header">
              <span 
                ><i class="el-icon-collection"></i> 本月完成率</span
              >
            </div> -->
                  <PanelGroupII
                    @handleSetLineChartData="handleSetLineChartData"
                    :biNumberItem="biNumberItem"
                  />
                </el-card>
              </el-col>
            </el-row>
          </section>

          <section id="section4">
            <!-- margin-bottom: 16px  -->
            <el-row :gutter="10" style="margin-bottom: 16px">
              <el-col :span="24">
                <el-card>
                  <div
                    slot="header"
                    class="card-box"
                    style="display: flex; justify-content: space-between"
                  >
                    <span
                      ><i class="el-icon-collection"></i>
                      {{
                        salesGrade.join(" ") + " "
                      }}整体销售趋势（销售额/达成率）</span
                    >
                    <!-- <timeSearch
                @getDateArr="getDateArr"
                @changDay="changDay"
                :timeArr="timeArr"
                :dayActive="this.dayActive"
                :dayLimit="1095"
              /> -->
                  </div>
                  <!-- <chartData :chartData="echartDataSku" /> -->
                  <div
                    class="el-table el-table--enable-row-hover el-table--medium chart-container"
                  >
                    <MinChart
                      :id="'echartDataMin'"
                      :minchartData="echartDataMin"
                      height="450px"
                      width="100%"
                      @SetLineChartData="SetLineChartData"
                    />
                  </div>
                </el-card>
              </el-col>
            </el-row>
          </section>

          <section id="section5">
            <el-row :gutter="10" style="background: #fff; margin-bottom: 16px">
              <!-- <h4
          style="
            font-weight: 600;
            color: #666;
            margin-left: 5px;
            margin-top: 25px;
          "
        > </h4>-->
              <el-col :span="12">
                <el-card>
                  <div
                    slot="header"
                    class="card-box"
                    style="display: flex; justify-content: space-between"
                  >
                    <span>
                      <i class="el-icon-s-data" style="margin-right: 5px" />{{
                        salesGrade.join(" ") + " "
                      }}<span style="margin-right: 5px">{{
                        queryParams.dataDate
                          ? queryParams.dataDate
                          : queryParams.dataYear + "-" + queryParams.dataMonth
                      }}</span
                      >品牌销售额
                    </span>
                    <span></span>
                  </div>
                  <!-- <el-row :gutter="10">
                  <el-col :span="12"> -->
                  <!-- :minchartData="echartDataMin"
                height="410px"
                width="100%"
                @SetLineChartData="SetLineChartData" -->

                  <PieChart
                    :id="'className'"
                    :chartData="PieChartData"
                    @SetPieChartData="SetPieChartData"
                  />
                </el-card>
                <!-- </el-col> -->
              </el-col>
              <el-col :span="12">
                <el-card>
                  <div
                    slot="header"
                    class="card-box"
                    style="display: flex; justify-content: space-between"
                  >
                    <span>
                      <i class="el-icon-s-data" style="margin-right: 5px" />{{
                        salesGrade.join(" ") + " "
                      }}<span style="margin-right: 5px">{{
                        queryParams.dataDate
                          ? queryParams.dataDate
                          : queryParams.dataYear + "-" + queryParams.dataMonth
                      }}</span
                      >销售增长排名
                    </span>
                    <span></span>
                  </div>
                  <div
                    style="
                      margin-left: 2px;
                      margin-right: 2px;
                      width: 100%;
                      height: 350px;
                    "
                    ref="barecharts"
                  ></div>
                  <!-- <ve-bar
                  :settings="{
                    label: {
                      show: true,
                      position: 'top',
                      formatter: '{c}%',
                    },
                  }"
                  :data="barChartData"
                  style="height: 350px"
                  :extend="{ series: { barWidth: 15 } }"
                ></ve-bar> -->
                </el-card>
              </el-col>
            </el-row>

            <!-- </el-row> -->
          </section>
        </section>
      </el-tab-pane>
      <el-tab-pane label="渠道销售追踪" name="1">
        <channel v-if="activeName == 1" :query="query" />
      </el-tab-pane>
      <el-tab-pane label="店铺销售追踪" name="2">
        <shopName v-if="activeName == 2" :query="query" />
      </el-tab-pane>
    </el-tabs>

    <!-- <section id="section7">
      <el-row :gutter="10" style="padding: 16px 0">
        <el-col :span="17">
          <el-card>
            <div slot="header">
              <span><i class="el-icon-collection"></i> 店铺库存排行</span>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </section>

    <section id="section8">
      <el-row :gutter="10">
        <el-col :span="10">
          <el-card style="height: calc(100vh - 125px)">
            <div slot="header">
              <span><i class="el-icon-collection"></i> 销售地区Top20</span>
            </div>
          </el-card>
        </el-col>

        <el-col :span="14">
          <el-card style="height: calc(100vh - 125px)">
            <div ref="platform" style="width: 1100px; height: 960px"></div>
          </el-card>
        </el-col>
      </el-row>
    </section> -->
  </div>
</template>

<script>
import {
  listBiSaleAmount,
  getBiSaleAmount,
  delBiSaleAmount,
  addBiSaleAmount,
  updateBiSaleAmount,
  synData,
  selectSaleTracking,
  selectSaleTargetStatistics,
  //饼图
  brandSaleAmount,
  //环比
  channelSaleAmountYoy,
} from "@/api/sale/BiSaleAmount";
import { getCache } from "@/api/monitor/cache";
// import echarts from "echarts";
import * as echarts from "echarts/lib/echarts.js";
require("echarts/extension/bmap/bmap");
import "echarts/map/js/china.js"; //引入中国地图数据
import city from "echarts/map/json/china-cities.json";
import date from "./day/date.vue";
import chartDataI from "./components/chartDataI";
import chartData from "./components/chartData";

import MinChart from "@/views/sale/order/Chart/MinChart.vue";
import MixChart from "./Chart/MixChart.vue";
import timeSearch from "./day/day.vue";
import exhaustionDay from "./day/exhaustionDay.vue";
// import waterLevelChart from "./waterLevelChart";
import progressMonthly from "./components/progressMonthly";
import progressYear from "./components/progressYear";
import card from "./Chart/card.vue";
import cardquarterly from "./Chart/cardquarterly.vue";
import cardyear from "./Chart/cardyear.vue";

import channel from "./channel/index.vue";
import shopName from "./shopName/index.vue";
import PanelGroup from "./components/PanelGroup";
import PanelGroupI from "./components/PanelGroupI";
import PanelGroupII from "./components/PanelGroupII";
// import LineChart from './components/LineChart'
import chartDataRaddar from "./components/chartDataRaddar";
import RaddarChart from "./components/RaddarChart";
import PieChart from "./components/PieChart";
import BarChart from "./components/BarChart";
import { firstThreeScreenRank } from "@/api/sku/BiSkuSaleDwd";
import {
  numberOfItem,
  TopSaleProvince,
  synchroChannelData,
} from "@/api/chart/BiChannelSaleDwd";
import {
  selectChannelStatistics,
  selectSaleSingle,
  channelSaleTop,
  shopSaleTop,
  selectInventoryData,
  selectInvStatistics,
  getchannelInventoryTop,
  getshopInventoryTop,
  selectFirstStatistics,
  selectAllFirstThreeList,
} from "@/api/chart/SaleDwd";

import { listBrandChannelShop, listAll } from "@/api/chart/brandChannelShop";

const lineChartData = {};

export default {
  name: "Admin",
  dicts: [
    "sys_product_item",
    "sys_product_secondary",
    "sys_product_cycle",
    "sys_product_pl",
    "sys_product_pp",
  ],
  components: {
    chartDataRaddar,
    // GithubCorner,
    PanelGroup,
    PanelGroupI,
    PanelGroupII,
    card,
    cardquarterly,
    cardyear,
    progressMonthly,
    progressYear,
    // LineChart,

    // RaddarChart,
    PieChart,
    BarChart,

    chartData,
    chartDataI,
    MinChart,
    MixChart,
    // TransactionTable,
    // TodoList,
    // BoxCard
    timeSearch,
    exhaustionDay,
    date,
    channel,
    shopName,
  },
  data() {
    return {
      brandList: ["VFU"],
      activeName: 0,
      color: [
        function (val) {
          if (val <= 38) {
            return "#ff4d4f";
          }
          return "#2194ff";
        },
      ],
      query: {},
      // 店铺
      cascadeList: [],
      // , "天猫", "vfu运动旗舰店"
      salesGrade: [],
      typeArr: [
        { value: "month", label: "MTD" },
        { value: "quarterly", label: "QTD" },
        { value: "year", label: "YTD" },
      ],
      dateType: "month",
      //
      barChartData: {
        columns: [],
        rows: [],
      },
      //环比
      PieData: [],
      //趋势图
      skcitemData: [],
      //饼图
      PieChartData: {
        // order: {
        xData: [],
        female: [],
        // male: [],
        // average: [],
      },
      echartDataMin: {
        // order: {
        xData: [],
        female: [],
        male: [],
        average: [],
      },
      echartData: {
        value: 0,
        name: "",
        bg: "",
      },
      echartDataquarterly: {
        value: 0,
        name: "",
        bg: "",
      },
      echartDatamonthly: {
        value: 0,
        name: "",
        bg: "",
      },

      //品类属性
      itemType: [],
      //价格带
      list: [],
      //多选品类
      formData: {
        libraryIdList: [{ id: "" }],
      },
      libraryOptions: [], // 库存名称列表

      //雷达图
      echartDataRaddar: [],
      //总览数据
      itemData: {},
      // 总条数
      total: 0,
      // 查询参数
      queryParams: {
        // pageNum: 1,
        // pageSize: 10,
        // property: "salesAmount",
        // firstLevelList: null,
        // secondLevelList: null,
        // threeLevelList: null,
      },
      //商品排行
      ItemDateList: [],
      //产品视角
      productView: "一级",

      //锚点
      sections: document.querySelectorAll("section"),
      activeSection: null,
      active: null,
      scrollTimer: null,
      //地区前20
      TopSallist: [],
      tableHeight: window.innerHeight - 175,
      pageHeight: window.innerHeight - 280,
      itemHeight: window.innerHeight - 680,
      shopListHeight: window.innerHeight - 570,
      //BI指标数据
      biNumberItem: {},
      biNumberSku: [],
      //时间控件
      timeObj: {},
      //客单价
      biNumberOfItem: "",

      //时间控件
      valueTime: new Date(new Date().setDate(new Date().getDate() - 1)),
      groupType: "date",

      highlighted: ["销售金额", "退款金额", "净销售额"], // 初始化时，前两个元素高亮

      //传递数据
      // echartData: {
      //   columns: ["支付日期", "销售金额", "退款金额", "净销售额"],
      //   rows: [],
      // },
      highlightedSku: ["库存总金额", "产品库存总金额", "配件库存总金额"], // 初始化时，前两个元素高亮

      //Sku传递数据
      echartDataSku: {
        columns: ["支付日期", "销售目标", "销售额", "达成率"],
        rows: [],
      },
      //时间
      dayActive: 15,
      monthActive: false,
      timeArr: [
        // { value: "2", label: "昨天" },
        { value: "15", label: "最近15天" },
        // { value: "30", label: "最近30天" },
        { value: "365", label: "月" },
        { value: "1", label: "日" },
      ],
      timeGap: { startTime: "", endTime: "" },

      loading: false,
      //店铺名称
      shopName: "",
      mapData: [],
      lineChartData: lineChartData.newVisitis,
    };
  },
  created() {
    this.getList();

    // this.handleChangeTime()
    /** 查询品牌渠道店铺关系列表 */
    this.getdataSourceList();
    // this.openLoading();
  },
  // mounted() {
  //   this.$store.dispatch("app/toggleSideBarHide", fa);
  // },
  watch: {
    salesGrade: {
      handler: function (newnew, oldold) {
        // console.log(JSON.stringify(newnew));
        this.query = {
          salesGrade: this.salesGrade.join(","),
          dateType: this.dateType,
        };
        // this.getselectSaleTargetStatistics();
      },
      deep: true,
      immediate: true,
    },
    // monthActive: {
    //   handler: function (newnew, oldold) {

    //     if (!this.timeGap.endTime) {
    //       return;
    //     }
    //     let obj = {};
    //     if (this.monthActive) {
    //       obj = {
    //         dateType: "month",
    //         salesGrade: this.salesGrade.join(","),
    //       };
    //     } else {
    //       obj = {
    //         dateType: "date",
    //         ...this.timeGap,
    //         salesGrade: this.salesGrade.join(","),
    //       };
    //     }
    //
    //   },
    //   deep: true,
    //   immediate: true,
    // },
  },
  mounted() {
    window.addEventListener("scroll", this.startScrollTimer);
  },
  beforeDestroy() {
    window.removeEventListener("scroll", this.startScrollTimer);
  },

  methods: {
    handleClick(tab, event) {},
    //指标点击回传
    handleSetLineChartData(type) {},

    getselectSaleTargetStatistics() {
      this.query = {
        salesGrade: this.salesGrade.join(","),
        dateType: this.dateType,
      };
      selectSaleTargetStatistics(this.query).then((response) => {
        this.queryParams = {};
        this.queryParams.company = this.salesGrade[0];
        this.queryParams.dataYear = response[response.length - 1].dataYear;
        this.queryParams.dataMonth = response[response.length - 1].dataMonth;
        if (response[response.length - 1].dataDate) {
          this.queryParams.dataDate = response[response.length - 1].dataDate;
        }

        this.getskuBySkcSaleList();

        response.forEach((item, index) => {
          item.id = index;
        });
        this.skcitemData = response;
        this.echartDataMin.xData = response.map((item) => item.dataDateUnit);
        //销售目标
        this.echartDataMin.female = response.map((item) =>
          item.saleTarget ? item.saleTarget : null
        );
        //销售额
        this.echartDataMin.male = response.map((item) => item.saleAmount);
        //达成率
        this.echartDataMin.average = response.map(
          (item) => item.completionRate
        );
        // }
        return;
      });
    },
    //skc图表点击
    SetLineChartData(index) {
      console.log(index);
      this.skcitemData.forEach((item) => {
        if (index == item.id) {
          console.log(JSON.stringify(item));
          // let obj = {
          //   dataYear: item.dataYear,
          //   dataMonth: item.dataMonth,
          //   company: this.salesGrade[0],
          // };
          this.queryParams = {};
          if (!item.dataDate) {
            this.queryParams.dataYear = item.dataYear;
            this.queryParams.dataMonth = item.dataMonth;
          } else {
            this.queryParams.dataYear = item.dataYear;
            this.queryParams.dataMonth = item.dataMonth;
            this.queryParams.dataDate = item.dataDate;
          }

          this.queryParams.company = this.salesGrade[0];
          this.getskuBySkcSaleList();
        }
      });
    },
    //饼图点击
    SetPieChartData(index) {
      this.PieData.forEach((item) => {
        if (index == item.id) {
          // let obj = {
          //   dataYear: item.dataYear,
          //   dataMonth: item.dataMonth,
          //   company: this.salesGrade[0],
          // };
          // this.queryParams.dataYear = item.dataYear;
          // this.queryParams.dataMonth = item.dataMonth;
          // this.queryParams.company = this.salesGrade[0];

          this.getchannelSaleAmountYoy(item.brand);
        }
      });
    },
    //环比
    getchannelSaleAmountYoy(brand) {
      let obj = {
        label: "channel",
        brand: brand,
        ...this.queryParams,
      };

      channelSaleAmountYoy(obj).then((response) => {
        // this.barChartData.columns = ["gpuType", "val1", "val2"];
        // this.barChartData = {
        //   columns: [],
        //   rows: [],
        // };
        // this.barChartData.columns.push("渠道", "销售增长率");
        // response.forEach((item) => {
        //   this.barChartData.rows.push({
        //     渠道: item.channel,
        //     销售增长率: item.saleAmountYoy,
        //   });
        // });
        // if (response.length == 0) {
        //   var myChartDom = this.$refs.barecharts;

        //   // 检查是否已经存在ECharts实例
        //   if (echarts.getInstanceByDom(myChartDom)) {
        //     // 如果存在，销毁它
        //     echarts.getInstanceByDom(myChartDom).dispose();
        //   }
        //   return;
        // }
        const channel = response.map((item) => item.channel);
        const saleAmountChain = response.map((item) =>
          item.saleAmountChain ? item.saleAmountChain : 0
        );

        const option = {
          tooltip: {
            trigger: "axis",
            formatter: "{a} <br/>{b}:{c}%",
          },
          grid: {
            top: 80,
            bottom: 30,
          },
          xAxis: {
            type: "value",
            position: "top",
            splitLine: {
              lineStyle: {
                type: "dashed",
              },
            },
          },
          yAxis: {
            type: "category",
            axisLine: { show: false },
            axisLabel: { show: false },
            axisTick: { show: false },
            splitLine: { show: false },
            data: channel,
          },
          series: [
            {
              name: "销售增长率",
              type: "bar",
              stack: "Total",
              barWidth: 15,
              label: {
                position: "right",
                show: true,
                formatter: "{b}:{c}%",
              },
              data: saleAmountChain,
              itemStyle: {
                normal: {
                  color: function (params) {
                    var index_color = params.value;

                    if (index_color < 0) {
                      return "#fe4365";
                    } else {
                      return "#25daba";
                    }
                  },
                },
              },
            },
          ],
        };

        //   myChart.setOption(option);
        var myChartDom = this.$refs.barecharts;

        // 检查是否已经存在ECharts实例
        if (echarts.getInstanceByDom(myChartDom)) {
          // 如果存在，销毁它
          echarts.getInstanceByDom(myChartDom).dispose();
        }

        // 初始化新的ECharts实例
        var myChart = echarts.init(myChartDom);
        // if (response.length == 0) {
        //   return;
        // } else {
        myChart.setOption(option);
      });
    },
    //饼图
    getskuBySkcSaleList() {
      if (this.query.dateType == "month") {
        this.queryParams.dateType = "date";
      } else {
        this.queryParams.dateType = "month";
      }

      brandSaleAmount(this.queryParams).then((response) => {
        console.log(JSON.stringify(response));
        if (response.length < 1) {
          return;
        }

        response.forEach((item, index) => {
          item.id = index;
        });
        // this.skcitemData = response;
        this.PieData = response;
        this.getchannelSaleAmountYoy(this.PieData[0].brand);
        if (response) {
          let row = [];
          response.forEach((item) => {
            row.push({
              value: item.saleAmount,
              name: item.brand,
            });
          });
          // this.PieChartData.female
          this.PieChartData.xData = response.map((item) => item.brand);
          this.PieChartData.female = row;
        }
      });
    },
    //销售指标
    getselectSaleSingle(value) {
      let obj = { brandList: this.brandList };
      selectSaleTracking(obj).then((response) => {
        if (response) {
          this.biNumberItem = response ? response : {};
          this.echartData.value = response.yearCompletionRate;
          this.echartData.name = "年度完成率";
          if (response.yearCompletionRate > response.yearProgress) {
            this.echartData.bg = "#2ba245";
          } else {
            this.echartData.bg = "#ff3334";
          }

          this.echartDataquarterly.value = response.quarterlyCompletionRate;
          this.echartDataquarterly.name = "季度完成率";
          if (response.quarterlyCompletionRate > response.quarterlyProgress) {
            this.echartDataquarterly.bg = "#2ba245";
          } else {
            this.echartDataquarterly.bg = "#ff3334";
          }

          this.echartDatamonthly.value = response.monthlyCompletionRate;
          this.echartDatamonthly.name = "本月完成率";
          if (response.monthlyCompletionRate > response.monthlyProgress) {
            this.echartDatamonthly.bg = "#2ba245";
          } else {
            this.echartDatamonthly.bg = "#ff3334";
          }
        }
        console.log(JSON.stringify(this.biNumberItem));
      });
    },
    changebrandList() {
      if (this.brandList.length == 0) {
        this.$modal.msgError("请选择至少一个品牌");
        return;
        // this.queryParams.brandList = this.brandList;
      }
      this.getselectSaleSingle();
    },
    //店铺控件
    handleChange(val) {
      this.getselectSaleSingle(this.salesGrade);

      return;
      // console.log(JSON.stringify(val));
      // // let obj = { salesGrade: this.this.salesGrade.join(","), ...this.timeObj };
      // let obj = { salesGrade: this.this.salesGrade.join(",") };
      // console.log(JSON.stringify(obj));

      // localStorage.removeItem("result");
      // // localStorage.setItem("result", JSON.stringify(obj));

      // if (!obj.endTime) {
      //   return;
      // } else {
      //   //销售指标

      //   //渠道库存Top
      //   this.channelInventoryTop(obj);
      //   //店铺库存Top
      //   this.shopInventoryTop(obj);
      //   //曲线
      //   this.getechartChannelData(obj);

      //   //渠道SaleTop
      //   this.getchannelSaleTop(obj);
      //   //店铺SaleTop
      //   this.getshopSaleTop(obj);
      //   //商品排行Top
      //   this.changeView();
      // }
      // let param = {
      //   dataSource: this.salesGrade,
      //   startTime: this.dateFormat(this.timeObj.startTime),
      //   endTime: this.dateFormat(this.timeObj.endTime),

      // };
      // console.log(JSON.stringify(param));
      // if (!param.endTime) {
      //   return;
      // } else {
      //   // this.getechartChannelData(obj)
      //   this.getnumberOfItem(param);
      //   this.getTopSal(param);
      // }
    },
    //选完时间后发请求
    handleChangeTime(timeObj) {
      // console.log(type)
      // console.log(timeObj)
      // TODO
      this.timeObj = timeObj;
      if (this.salesGrade.length <= 0) {
        return;
      }
      return;
      let param = {
        dataSource: this.salesGrade,
        startTime: this.dateFormat(timeObj.startTime),
        endTime: this.dateFormat(timeObj.endTime),
      };
      console.log(JSON.stringify(param));
      if (!param.endTime) {
        return;
      } else {
        // this.getechartChannelData(obj)
        //客件数
        this.getnumberOfItem(param);
        //地区Top20
        this.getTopSal(param);
      }
      console.log(JSON.stringify(this.timeObj));

      let obj = { salesGrade: this.this.salesGrade.join(",") };

      console.log(JSON.stringify(obj));

      localStorage.removeItem("result");
      localStorage.setItem("result", JSON.stringify(obj));

      if (!obj.endTime) {
        return;
      } else {
        //销售指标
        this.getselectSaleSingle(this.salesGrade);
        //渠道库存Top
        this.channelInventoryTop(obj);
        //店铺库存Top
        this.shopInventoryTop(obj);
        //曲线
        this.getechartChannelData(obj);

        //渠道SaleTop
        this.getchannelSaleTop(obj);
        //店铺SaleTop
        this.getshopSaleTop(obj);
        //商品排行Top
        this.changeView();
      }
    },
    //分页
    //售罄时间定义
    changePage() {},
    //视图角度
    changeView(val) {},

    // 时间格式转换
    dateFormat(date) {
      date = new Date(date);
      let Y = date.getFullYear() + "-";
      let M =
        (date.getMonth() + 1 < 10
          ? "0" + (date.getMonth() + 1)
          : date.getMonth() + 1) + "-";
      let D = date.getDate() < 10 ? "0" + date.getDate() : date.getDate() + "";
      return Y + M + D;
    },
    /** 查询品牌渠道店铺关系列表 */
    getdataSourceList() {
      listAll().then((response) => {
        let result = this.transformData(response);
        this.salesGrade = [result[0].label];
        this.cascadeList = result;
        //销售指标
        this.getselectSaleSingle(this.brandList);
      });
    },
    //店铺渠道品牌转换

    transformData(data) {
      let result = [];

      data.forEach((item) => {
        let brand = item.brand;
        // let channel = item.brand;
        // let shopName = item.shopName;

        // 如果brand在结果数组中不存在，则创建一个新的数组
        let brandIndex = result.findIndex(
          (brandObj) => brandObj.label === brand
        );
        if (brandIndex === -1) {
          result.push({
            label: brand,
            value: brand,
            // children: [],
          });
          brandIndex = result.length - 1;
        }

        // 如果channel在当前brand的children数组中不存在，则创建一个新的数组
        // let channelIndex = result[brandIndex].children.findIndex(
        //   (channelObj) => channelObj.label === channel
        // );
        // if (channelIndex === -1) {
        //   result[brandIndex].children.push({
        //     label: channel,
        //     value: channel,
        //     // children: [],
        //   });
        //   channelIndex = result[brandIndex].children.length - 1;
        // }

        // 如果shopName在当前channel的children数组中不存在，则创建一个新的数组
        // let shopIndex = result[brandIndex].children[
        //   channelIndex
        // ].children.findIndex((shopObj) => shopObj.label === shopName);
        // if (shopIndex === -1) {
        //   result[brandIndex].children[channelIndex].children.push({
        //     label: shopName,
        //     value: shopName,
        //     // children: []
        //   });
        // }
      });

      return result;
    },
    //锚点
    scrollToSection(index) {
      const target = this.sections[index];
      // console.log(JSON.stringify(index));
      //     return
      this.active = index;
      if (target) {
        this.$nextTick(() => {
          target.scrollIntoView({ behavior: "smooth" });
          this.activeSection = target;
        });
      }
    },
    //锚点
    startScrollTimer() {
      this.scrollTimer = setInterval(() => {
        const currentSection = document.querySelector("section[data-active]");
        if (currentSection !== this.activeSection) {
          this.activeSection = currentSection;
        } else {
          clearInterval(this.scrollTimer);
        }
      }, 100); // 每100毫秒检查一次滚动位置是否变化
    },
    //锚点高亮
    isActiveSection(sectionId) {
      // 检查当前导航项是否处于高亮状态
      return this.active === sectionId;
    },
    /** 查缓存询信息 */
    getList() {},
    // 打开加载层
    openLoading() {
      this.$modal.loading("正在加载分析销售监控数据，请稍候！");
    },
    //地区Top20
    getTopSal(param) {},
  },
};
</script>

<style lang="scss" scoped>
.el-tabs--card {
  height: calc(100vh - 110px);
  /* overflow-y: auto; */
}
.el-tab-pane {
  height: calc(100vh - 110px);
  overflow-y: auto;
}
::v-deep .el-tabs__content {
  /* height: 185px;
  border-radius: 4px; */
  background-color: rgb(240, 242, 245) !important; /* 使用你想要的蓝色 */
}
.el-dialog-div {
  height: 100vh;
  overflow-x: hidden;
}
.content {
  display: flex;
  justify-content: center;
  align-items: center;
}
/* 移除默认的列表样式 */
ul {
  margin-top: 0.4%;
  list-style-type: none;
  /* 设置弹性布局，使列表项横向排列 */
  display: flex;
  /* 添加一些内边距和背景颜色 */
  // padding: 10px;
  margin-right: 10px;
  /* 设置边框和圆角 */
  // border: 1px solid #ddd;
  border-radius: 5px;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
}

/* 设置列表项样式 */
li {
  /* 添加一些内边距和右边距 */
  // padding: 10px;
  margin-right: 10px;
  /* 设置链接文本样式 */
  font-size: 15px;
  color: #bbb;
  text-decoration: none;
}

li.active a {
  // color: #f00;
  /* 高亮颜色 */
  color: #fff;
  background-color: #40c9c6;
}

// section {
//   margin-top: 60px;
// }

.dashboard-editor-container {
  // padding: 16px;
  background-color: rgb(240, 242, 245);
  position: relative;

  .github-corner {
    position: absolute;
    top: 0px;
    border: 0;
    right: 0;
  }

  .chart-wrapper {
    background: #fff;
    padding: 16px 16px 0;
    margin-bottom: 16px;
  }
}

@media (max-width: 1024px) {
  .chart-wrapper {
    padding: 8px;
  }
}
// .train-tree-cascader {
//   height: 500px !important;
// }

// .el-scrollbar__wrap {
//   overflow: initial !important;
// }
</style>
private Double monthlyCompletionRate;//本月完成率
private Double:yesterdaySales;//昨日销售额
private Double yesterdaySalesYoy;// 昨日销售额同比
private Double:yesterdaySalesChain;//昨日销售额环比
:weeklySales;//本周销售额private Double
private Double weeklySalesYoy;//本周销售额同比
private Double weeklySalesChain;//本周销售额环比
private Double monthlySales;//本月销售额
private Double monthlySalesYoy;// 本月销售额同比
private Double monthlySaleschain;//本月销售额环比
private Double:monthlySalesTarget;//月销售目标
private Double monthlyReturnAmount;//月退货金额
private Double monthlyReturnAmountYoy;// 月退货金额同比
private Double monthlyReturnAmountChain;//月退货金额环比
private Double monthlyNetSaleAmount;//月净销售额
private Double monthlyNetSaleAmountYoy;//月净销售额同比private Double monthlyNetSaleAmountchain;//月净销售额环比
private Integer monthlyOrderCount;//月订单数
private Double monthlyOrderCountYoy;// 月订单数同比
private Double monthlyOrderCountChain;// 月订单数环比
private Double monthlyCustomerPrice;//月客单价
private Double monthlyCustomerPriceYoy;// 月客单价同比private Double monthlycustomerPricechain;//月客单价环比
private Double quarterlycompletionRate;//李度完成率
private Double salesTargetQuarterly;//李销售目标
private Double:quarterlySales;//季度销售额
private Double quarterlySalesYoy;//李度销售额同比
private Double quarterlySaleschain;//李度销售额环比
private Double:quarterlyReturnAmount;//季度退货金额
private Double quarterlyReturnAmountYoy;//季度退货金额同比private Double quarterlyReturnAmountchain;// 李度退货金额环比
private Double quarterlyNetSaleAmount;//李度净销售额
private Double quarterlyNetSaleAmountYoy;// 李度净销售额同比private Double quarterlyNetSaleAmountchain;// 李度净销售额环比


private Double quarterlyNetSaleAmountchain;李度净销售额环
private Integer quarterlyOrderCount;// 李度订单数
private Double quarterlyOrderCountYoy;// 李度订单数同比
private Double quarterlyOrderCountChain;//李度订单数环比
private Double quarterlyCustomerPrice;// 李度客单价
private Double quarterlycustomerPriceYoy;// 李度客单价同比
private Double quarterlyCustomerPricechain;// 李度客单价环比
private Double yearCompletionRate;//年度完成率
private Double yearsales;// 年度销售额
private Double yearSalesChain;//年度销售额
private Double yearSalesYoy;// 年度销售额
private Double salesTargetYear;// 年销售目标
private Double yearReturnAmount;// 年度退货金额
private Double yearReturnAmountYoy;//年度退货金额同比
private Double yearReturnAmountChain;//年度退货金额环比
private Double yearNetSaleAmount;// 年度净销售额
private Double yearNetSaleAmountYoy;// 年度净销售额同比private Double yearNetSaleAmountChain;// 年度净销售额环比
private Integer yearOrderCount;// 年度订单数
private Double yearOrderCountYoy;//年度订单数同比
private Double year0rderCountchain;//年度订单数环比
private Doublee yearCustomerPrice;//年度客单价
private Double yearCustomerPriceYoy;// 年度客单价同比
private Double yearCustomerPricechain;//年度客单价环比


/** 店铺id */
dExcel(name =“店铺id")
private string shopId;
/** 店铺名称 */
0Excel(name =“店铺名称")
private string shopName;
/** 销售额 */
0Excel(name =“销售额")
private Double saleAmount;
private Double saleAmountChain;//环比private Double saleAmountYoy;//同比
扩展字段不用放
/** 退款金额 */
@Excel(name =“退款金额")
private Double returnAmount;
/** 净销售额 */
0Excel(name ="净销售额")
private Double netSalesAmount;
/*疜婀憎弗昃箧瞎摶⓪愧粕呷黯湘乾喏藔齔盉綺谆仍单数 */
@Excel(name =“下单数")
private Integer ordersNumber;
/** 下单数 */
@Excel(name =“下单数")
private Double customerUnitPrice;
/** 日期 */
dJsonFormat(pattern ="yyyy-MM-dd")
@Excel(name ="期",width=30,dateFormat ="yyyy-MM-dd")private Date dataDate;